<?php
/**
 * This is the index.ctp of Administration Controller
 * @author Arsene Tochemey GANDOTE<arsene.gandote@yahoo.com>
 * @access public
 * @version 1.0
 * @copyright (c) 2011 - Tochemey. You are free to use this class.
 * 				  Modify it the way you want it.
 * 				  Please let me know about any modifications done.
 */

?>
<?php 
$userModules =  $userData['Module'];

//echo debug($userData);

$x = 0;
$start_tag = '<tr>';
$end_tag = '</tr>';
$output_str = '';

   
if(!empty($userModules)){
    foreach($userModules as $module){
        $url_array = explode('/', $module['url']);
        $img = $this->Html->image($module['icon'], array('alt' => $module['name'],'border'=>0));
      
      if($x == 0){
          $output_str .= $start_tag . "<td><div class='dash_btn '><div class='icon'> <div class='holder'>".$this->Html->link($img, array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div>";
          $output_str .= "<div class='link'> <div class='holder'>".$this->Html->link($module['name'], array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div></div></td>";
        $x++;
      }
      else if($x == 1){
         $output_str .= "<td><div class='dash_btn '><div class='icon'> <div class='holder'>".$this->Html->link($img, array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div>";
         $output_str .= "<div class='link'> <div class='holder'>".$this->Html->link($module['name'], array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div></div></td>";
         $x++;
      }
      else if($x == 2){
         $output_str .= "<td><div class='dash_btn '><div class='icon'> <div class='holder'>".$this->Html->link($img, array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div>";
         $output_str .= "<div class='link'> <div class='holder'>".$this->Html->link($module['name'], array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div></div></td>";
         $x++;
      }
      else if($x == 3){
         $output_str .= "<td><div class='dash_btn '><div class='icon'> <div class='holder'>".$this->Html->link($img, array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div>";
         $output_str .= "<div class='link'> <div class='holder'>".$this->Html->link($module['name'], array('controller' =>  $url_array[0], 'action' => $url_array[1]),array('class'=>'','escape'=>false))."</div></div></div></td>".$end_tag;
         $x = 0;
      }
    }
}
else{
    $output_str = $start_tag. "<td> <div class='dashboard-cell' style=''>You Do Not Have Any Assign Modules.</div></td>" .$end_tag;
}
				  
?>
<div class="dashboard-container">
       <div class="dashboard-content">
            <table border="0" width="100%" >
                <?php echo $output_str; ?>
            </table>
       </div>
</div>

<script type="text/javascript">
/* when the page is loaded */
$(document).ready(function() {    
   $('.dash_btn a').click(function(){
        $(this).parent().parent().parent().addClass('active');
        
        //return false;
   });
});
</script>
